package com.yx.modules.api.controller;

import com.yx.common.annotation.Log;
import com.yx.common.utils.R;
import com.yx.system.entity.TdBook;
import com.yx.system.entity.TdOnlinePayLog;
import com.yx.system.service.TdOnlinePayLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 支付记录控制器
 */
@RestController
@RequestMapping("/api/onlinePayLog")
public class TdOnlinePayLogController {

    @Autowired
    private TdOnlinePayLogService tdOnlinePayLogService;

    /**
     * 按ID查询支付记录
     *
     * @return
     */
    @PostMapping("findByUid")
    public R findByUId(int id) {
        return R.ok().put("user", tdOnlinePayLogService.selectByPrimaryKey(id));
    }

    /**
     * 新增或修改
     *
     * @return
     */
    @PostMapping("saveOrUpdate")
    public R saveOrUpdate(TdOnlinePayLog tdOnlinePayLog) {
        if (tdOnlinePayLog.getId() == 0 || tdOnlinePayLog.getId() == null) {
            tdOnlinePayLogService.insert(tdOnlinePayLog);
        } else {
            tdOnlinePayLogService.updateByPrimaryKey(tdOnlinePayLog);
        }
        return R.ok();
    }

    /**
     * 删除
     *
     * @return
     */
    @PostMapping("delete")
    public R delete(int id) {
        tdOnlinePayLogService.deleteByPrimaryKey(id);
        return R.ok();
    }
}
